<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <h1>员工管理系统</h1>
    <div v-if="isLogin">
        <a href="">注册</a>
        <a href="javascript:void(0)" v-on:click="f()">登录</a>
    </div>

    <div v-else>
        <input type="text" v-model="name" placeholder="员工姓名">
        <input type="button"   value="添加" @click="add()">
        <a href="javascript:void(0)" v-on:click="f1()">退出登录</a>
    </div>

    <table border="1">
        <caption>员工列表</caption>
        <tr>
            <th>编号</th>
            <th>姓名</th>
            <th v-show="!isLogin">操作</th>
        </tr>
        <tr v-for="(name,i) in arr">
            <td>{{i+1}}</td>
            <td>{{name}}</td>
            <td v-show="!isLogin" ><a href="javascript: void(0)" v-on:click="del(i)" >删除</a>
            </td>
        </tr>

    </table>
</div>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script>
    let v = new Vue({
        el: "body>div",
        data: {
            isLogin: true,
            arr:["猪猪","健健"],
            name:""
        },
        methods: {
            f() {
                v.isLogin = false;
            },
            f1() {
                v.isLogin = true;
            },
            add(){
                v.arr.push(v.name);
            },
            del(i){
                v.arr.splice(i,1);
            }

        }
    })

</script>
</body>
</html>